<template>
	<view class="fruit-container">
		<!-- 搜索 -->
		<view class="search">
			<u-icon name="search" size="20" color="#9098A0"></u-icon>
			<view class="content">输入你想要的东西</view>
		</view>

		<!-- 轮播 -->
		<cusSwiper></cusSwiper>

		<!-- 卡片  -->
		<view class="card-container">
			<view class="card-box">
				<view class="name">鲜切水果</view>
				<view class="mini-price">低至0.01</view>
				<view class="image-box">
					<image
						src="https://img1.baidu.com/it/u=2139106487,2811568658&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889"
						class="img"></image>
				</view>
			</view>
			<view class="card-box">
				<view class="name">鲜切水果</view>
				<view class="mini-price">低至0.01</view>
				<view class="image-box">
					<image
						src="https://img1.baidu.com/it/u=2139106487,2811568658&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889"
						class="img"></image>
				</view>
			</view>
			<view class="card-box">
				<view class="name">鲜切水果</view>
				<view class="mini-price">低至0.01</view>
				<view class="image-box">
					<image
						src="https://img1.baidu.com/it/u=2139106487,2811568658&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889"
						class="img"></image>
				</view>
			</view>
			<view class="card-box">
				<view class="name">鲜切水果</view>
				<view class="mini-price">低至0.01</view>
				<view class="image-box">
					<image
						src="https://img1.baidu.com/it/u=2139106487,2811568658&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889"
						class="img"></image>
				</view>
			</view>
		</view>

		<!-- 广告 -->
		<view class="advertising">
			<image src='https://cdn.uviewui.com/uview/swiper/swiper3.png' class="img"></image>
		</view>

		<!-- 分类 -->
		<!-- @click="click" -->
		<u-tabs :list="list1" class="tabs-box"></u-tabs>

		<!-- shop -->
		<view class="shop-container">
			<view class="shop-item" v-for="item in categoryInfo" :key="item.id">
				<view class="shop-top">
					<view class="img-box">
						<image :src="item.avatar" class="img"></image>
					</view>
					<view class="shop-info">
						<view class="name">{{item.name}}</view>
						<view class="discription">
							<view class="price">起送￥{{item.sendPay}} 配送￥2</view>
							<view class="time">{{item.time}}分钟 <text class="dis">{{item.distance}}m</text></view>
						</view>
						<view class="img-box">
							<image src="../../static/discount.png" class="img"></image>
						</view>
					</view>
				</view>
				<scroll-view scroll-x class="scroll-box">
					<view class="scroll-item" v-for="subitem in item.dishesList" :key="subitem.id">
						<view class="box">
							<view class="img-box">
								<image :src="subitem.picture" class="image"></image>
							</view>
							<view class="fruit-info">
								<view class="name">{{subitem.name}}</view>
								<view class="price">￥15<text class="origin">￥19</text></view>
							</view>
						</view>
					</view>
					
				</scroll-view>
			</view>
		</view>
		
	</view>
	</view>
	</view>
</template>

<script>
	import {
		reqCateShop
	} from '@/common/api.js'
	export default {
		data() {
			return {
				list5: [
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
				],
				index: 0,
				list1: [{
						name: '综合排序'
					},
					{
						name: '速度'
					},
					{
						name: '销量'
					},
					{
						name: '配送费'
					}
				],
				id: '',
				categoryInfo: []
			}
		},

		methods: {
			// 获取分类信息
			async getCateInfo() {
				const res = await reqCateShop(this.id)
				// console.log(res);
				if (res.code == 200) {
					this.categoryInfo = res.data
				}
			}
		},

		onLoad(options) {
			this.id = options.id
			this.getCateInfo()
		}

	}
</script>

<style lang="scss">
	.fruit-container {
		padding: 0 15px;

		.search {
			margin: 15px auto;
			width: 85%;
			background-color: #DEEDFF;
			color: #9098A0;
			height: 30px;
			line-height: 30px;
			display: flex;
			border-radius: 20px;
			padding: 0 20px;
		}

		.card-container {
			margin: 15px 0;
			display: flex;
			justify-content: space-evenly;

			.card-box {
				background-color: white;
				width: 22%;
				padding: 2px;
				border-radius: 10px;
				overflow: hidden;

				.name {
					font-weight: bold;
				}

				.mini-price {
					font-size: 12px;
					color: #9098A0;
				}

				.image-box {
					width: 100%;
					height: 80px;

					.img {
						width: 100%;
						height: 100%;
					}
				}
			}

		}

		.advertising {
			height: 80px;

			.img {
				width: 100%;
				height: 80px;
			}
		}

	}
.tabs-box {
	background-color: white;
	margin-top: 10px;
	border-radius: 5px;
}
	.shop-container {

		.shop-item {
			background-color: white;
			margin: 10px 0;
			border-radius: 10px;
			padding: 5px;
			.shop-top {
				display: flex;
				align-items: center;
				margin-bottom: 10px;

				.img-box {
					width: 80px;
					height: 80px;
					border-radius: 10px;
					overflow: hidden;
					margin-right: 15px;

					.img {
						width: 100%;
						height: 100%;
					}
				}

				.shop-info {
					.name {
						font-weight: bold;
					}
					.img-box {
						width: 180px;
						height: 20px;
						margin-top: 5px;
						.img {
							width: 100%;
							height: 100%;
						}
					}
					
					.discription {
						display: flex;
						margin-top: 10px;
						color: #9098A0;
						.time {
							margin-left: 30px;
							.dis {
								margin-left: 5px;
							}
						}
					}
				}
			}

			.scroll-box {
				width: 100%;
				display: flex;
				white-space: nowrap;
				overflow: hidden;

				.scroll-item {
					display: inline-block;
					width: 85px;
					overflow: hidden;
					.box {
						display: flex;
						flex-direction: column;
						align-items: center;
					}
					.img-box {
						width: 70px;
						height: 70px;
						overflow: hidden;
						border-radius: 10px;

						.image {
							width: 100%;
							height: 100%;
						}
					}

					.fruit-info {
						text-align: center;
						.name {
							font-size: 12px;
						}

						.price {
							color: red;
							.origin {
								color: #9098A0;
								font-size: 12px;
								text-decoration: line-through;
								margin-left: 5px;
							}
						}
					}
				}
			}
		}
	}
</style>
